package com.goldentrail.dataobject;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.goldentrail.neo4j.Neo4jNode;
import com.goldentrail.neo4j.Relationship;

/**
 * @author dey
 * 
 */
public class Node {

	private String nodeId = null;
	private String nodeTp = null; // Tp: Type: data, invocation
	private String nodeVl = null; // Vl: Value:
	private ArrayList<Node> dependsOnNodes = null;

	/**
	 * @return the nodeId
	 */
	public String getNodeId() {
		return nodeId;
	}

	/**
	 * @param nodeId
	 *            the nodeId to set
	 */
	public void setNodeId(String nodeId) {
		this.nodeId = nodeId;
	}

	/**
	 * @return the nodeTp
	 */
	public String getNodeTp() {
		return nodeTp;
	}

	/**
	 * @param nodeTp
	 *            the nodeTp to set
	 */
	public void setNodeTp(String nodeTp) {
		this.nodeTp = nodeTp;
	}

	/**
	 * @return the nodeVl
	 */
	public String getNodeVl() {
		return nodeVl;
	}

	/**
	 * @param nodeVl
	 *            the nodeVl to set
	 */
	public void setNodeVl(String nodeVl) {
		this.nodeVl = nodeVl;
	}

	/**
	 * @return the dependsOnNodes
	 */
	public ArrayList<Node> getDependsOnNodes() {
		return dependsOnNodes;
	}

	/**
	 * @param dependsOnNodes
	 *            the dependsOnNodes to set
	 */
	public void setDependsOnNodes(ArrayList<Node> dependsOnNodes) {
		this.dependsOnNodes = dependsOnNodes;
	}

	public Node() {
		// TODO Auto-generated constructor stub
	}
	
	public Node(String type, String id) {
		setNodeTp(type);
		setNodeId(id);
	}

	public JSONObject getJson() {
		JSONObject json = new JSONObject();
		try {
			json.put("type", getNodeTp());
			json.put("id", getNodeId());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return json;
	}

	public String getJsonString() {
		return getJson().toString();
	}
	
	@Override
	public String toString() {
		return getJsonString();
	}

}
